package com.ylz.sjzx.sio.sdk.client.engine;

import com.ylz.sjzx.sio.sdk.model.BaseSocketModel;
import com.ylz.sjzx.sio.sdk.model.ChatRoomMessage;
import io.netty.channel.group.ChannelGroup;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

/**
 * @author wiqi
 * @version 1.0
 * @date 2020/12/2
 */
public class ChannelChatEngine extends ChatEngine {

    public ChannelChatEngine(String chatRoomId) {
        super(chatRoomId);
    }

    @Override
    public void sendMsg(ChannelGroup channelGroup, ChatRoomMessage chatRoomMessage) {

        BaseSocketModel build =
                BaseSocketModel.builder().action(chatRoomMessage.getCmd()).param(chatRoomMessage.getMessage()).build();
        channelGroup.writeAndFlush(new TextWebSocketFrame(build.toCmdMessage()));
    }
}
